Test for `point` within an attachment in `mail-mode`
Posted
by
lawlist
on Stack Overflow
See other posts from Stack Overflow
or by lawlist
Published on 2014-08-19T04:05:30Z
Indexed on
2014/08/19
4:20 UTC
Read the original article
Hit count: 190
I'm looking for a better test to determine when point is within a hidden attachment in mail-mode
(which is used by wl-draft-mode
). The attachments are mostly hidden and look like this:
--[[application/xls
Content-Disposition: attachment; filename="hello-world.xls"][base64]]
The test of invisible-p
yields a result of nil
. I am current using the following test, but it seems rather poor:
(save-excursion
(goto-char (point-max))
(goto-char (previous-char-property-change (point)))
(goto-char (previous-char-property-change (point)))
(re-search-backward "]]" (point-at-bol) t)))
Any suggestions would be greatly appreciated.
Here is the full snippet:
(goto-char (point-max))
(cond
((= (save-excursion (abs (skip-chars-backward "\n\t"))) 0)
(insert "\n\n"))
((and
(= (save-excursion (abs (skip-chars-backward "\n\t"))) 1)
(not
(save-excursion
(goto-char (previous-char-property-change (point)))
(goto-char (previous-char-property-change (point)))
(re-search-backward "]]" (point-at-bol) t))))
(insert "\n")))
GOAL: If there are no attachments and no new lines at the end of the buffer, then insert \n\n
and then insert the attachment thereafter. If there is just one new line at the end of the buffer, then insert \n
and then insert the attachment thereafter. If there is an attachment at the end of the buffer, then do not insert any new lines.
© Stack Overflow or respective owner